#include<iostream>
#include<string>

class Student
{

    public:
        //构造函数可以重载
        Student()//无参构造函数
        {
            std::cout<<"无参构造函数！\n";
        };

        //当自定义了带参构造函数，编译器不再生成默认的构造函数
        Student(int id,const char *name)
        {   
            std::cout<<"带参构造函数！"<<std::endl;
            m_id=id;
            m_name=name;
        }
        Student(const Student& s)//拷贝构造函数：参数得是对象的常引用,不然会造成无限拷贝
        {
            std::cout<<"拷贝构造函数！"<<std::endl;
            m_id=s.m_id;
            m_name=s.m_name;

        }
        //赋值运算符的重载
        void operator=(Student& s)
        {
                std::cout<<"赋值运算符的重载"<<std::endl;
                m_id=s.m_id;
                m_name=s.m_name;
        }

        ~Student()//析构函数不能带参数，不能重载
        {
            std::cout<<"析构函数!"<<std::endl;
        }



    private:
        int m_id;
        std::string m_name;



};

int main()
{

    Student s(1,"zhangsan");//在定义对象时自动调用
    Student s2;
    s2=s;
    return 0;
}